#include <stdio.h>
#include <stdlib.h> // 添加这个头文件
#include "lib_td_cmd.h"

//

uint16_t cmd_list_int[] =
{
    CMD1,
    CMD2,
    CMD3,
    CMD4
};



void func_callback1(uint8_t cmd, uint8_t *msg, uint8_t len)
{
    // 处理cmd1的逻辑
    printf("func_callback1: cmd=%d, msg=%s, len=%d\n", cmd, msg, len);
}

void func_callback2(uint8_t cmd, uint8_t *msg, uint8_t len)
{
    // 处理cmd2的逻辑
    printf("func_callback2: cmd=%d, msg=%s, len=%d\n", cmd, msg, len);
}

void func_callback3(uint8_t cmd, uint8_t *msg, uint8_t len)
{
    // 处理cmd3的逻辑
    printf("func_callback3: cmd=%d, msg=%s, len=%d\n", cmd, msg, len);
}

void func_callback4(uint8_t cmd, uint8_t *msg, uint8_t len)
{
    // 处理cmd4的逻辑
    printf("func_callback4: cmd=%d, msg=%s, len=%d\n", cmd, msg, len);
}

// 命令与回调函数映射表
_FUNCCALLBACK callback_list[] =
{
    {CMD1, func_callback1},
    {CMD2, func_callback2},
    {CMD3, func_callback3},
    {CMD4, func_callback4}
};


int main() {
    printf("Hello, World!\n");

    // 初始化命令处理模块
    lib_td_cmd_init(callback_list, sizeof(callback_list) / sizeof(_FUNCCALLBACK));

    // 模拟接收命令并处理
    uint16_t cmd = CMD2;
    lib_td_cmd_poll_task(cmd, (uint8_t *)"Exec Cmd 2", 5);

    // 模拟接收命令并处理
    cmd = CMD1;
    lib_td_cmd_poll_task(cmd, (uint8_t *)"Exec Cmd 1", 5);


    system("pause");

    return 0;
}